/**
 * Created by dengxixi on 2017/6/28.
 */
import Qs from 'qs'
export default {
  // 初始 请求头信息(Basic Base64.encode(client_id:client_secret))
  authorizationValue: 'Basic YWRtaW46MTIzNDU2', // ZmViczoxMjM0NTY=',
  baseURL: process.env.VUE_APP_URL,
  // `baseURL` 将自动加在 `url` 前面，除非 `url` 是一个绝对 URL
  url: '', // `url` 是用于请求的服务器 URL
  method: 'POST',

  transformRequest: [function (data) {
    data = Qs.stringify(data)
    return data
  }],

  transformResponse: [function (data) {
    return JSON.parse(data)
  }],
  headers: {
    // 'Authorization': this.authorizationValue
    // 'Content-Type': 'application/x-www-form-urlencoded'
    // 'Content-Type': 'application/json'
  },
  params: {
  },
  data: {
  },

  paramsSerializer: function (params) {
    return Qs.stringify(params)
  },

  timeout: 3000,

  withCredentials: true, // default

  responseType: 'text', // json default ,arraybuffer, blob, document,json,text

  onUploadProgress: function (progressEvent) {
    // Do whatever you want with the native progress event
  },

  onDownloadProgress: function (progressEvent) {
    // Do whatever you want with the native progress event
  },

  maxContentLength: 3000,

  validateStatus: function (status) {
    return status >= 200 && status < 600
  },

  maxRedirects: 5 // default
}
